package com.example.mycarcalling.activity;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.NumberPicker;

import androidx.appcompat.app.AlertDialog;

import com.example.mycarcalling.R;

public class PassengerDialog {

    public final static String TAG = PassengerDialog.class.getSimpleName();

    private AlertDialog passengerDialog = null;
    private Button btn_confirm = null;
    private Button btn_cancel = null;
    private NumberPicker passengerNumberPicker = null;

    private View inflate;


    public Button getBtn_confirm() {
        return btn_confirm;
    }

    public Button getBtn_cancel() {
        return btn_cancel;
    }

    public NumberPicker getPassengerNumberPicker() {
        return passengerNumberPicker;
    }

    public PassengerDialog(Context context) {
        inflate = View.inflate(context,R.layout.dialog_get_passenger_number,null);

        btn_cancel = inflate.findViewById(R.id.btn_cancel_dialog);
        btn_confirm = inflate.findViewById(R.id.btn_confirm_dialog);
        passengerNumberPicker = inflate.findViewById(R.id.np_passenger_dialog);

        passengerDialog = new AlertDialog.Builder(context)
                //标题
                .setTitle("乘车人数")
                //不可点击外部区域取消对话框
                .setCancelable(false)
                //设置视图
                .setView(inflate)
                .create();

        passengerNumberPicker.setMinValue(1);
        passengerNumberPicker.setMaxValue(4);
        passengerNumberPicker.setValue(1);



    }

    public void show() {
        passengerDialog.show();
    }

    public void dismiss() {
        passengerDialog.dismiss();
    }
}
